<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>对象的增强</title>
</head>
<body>
    
</body>
<script>
    //es5 
    const person = {
        name:'shane',
        age:18,
        run:function(){
            console.log('running')
        }
    }

    // es 6 简写
    let name = 'Kitty'
    let age = 12
    const person2 = {
        name, // 变量名直接成key值  变量的值直接成value值
        age,
        run(){
            console.log('running')
        },
        walk(){
            console.log('walking')
        }

    }

    // 对象的属性是可以用表达式来创建的
    // obj1 = {
    //     [name+"newName"]:'Amy',
    //     [name+"newAge"]:15
    // }
    // console.log(obj1);

    // ...扩展符 对象的合并
    // console.log({...person2,...obj1});

    // Object.assign() 将对象复制到目标中，往里添加属性
    Object.assign(person,person2)
    console.log(person);

</script>
</html>